﻿// -----------------------------------------------------------------------
// <copyright file="Fueled.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex03.GarageLogic
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class Fueled : EnergySource
    {
        public Fueled(eEnergySourceType i_EnergySourceType)
        {
            this.m_EnergyType = i_EnergySourceType;
        }

        public override void RechargeEnergySource(float i_AmountToCharge, eEnergySourceType i_FuelType)
        {
            if (i_FuelType == this.m_EnergyType)
            {
                if (this.m_CurrentEnergyQuantity + i_AmountToCharge <= this.m_MaxEnergyCapacity)
                {
                    this.m_CurrentEnergyQuantity += i_AmountToCharge;
                }
                else
                {
                    throw new ValueOutOfRangeException(0, this.m_MaxEnergyCapacity - this.m_CurrentEnergyQuantity);
                }
            }
            else
            {
                throw new ArgumentException("Wrong fuel type!");
            }
        }

        public override StringBuilder GetEnergySourceDataPrint()
        {
            StringBuilder EnergyData = new StringBuilder();

            EnergyData.Append("This vehicle is: " + this.m_EnergyType.ToString() + System.Environment.NewLine);
            EnergyData.Append("The maximum tank volume is: " + this.m_MaxEnergyCapacity + " liters" + System.Environment.NewLine);
            EnergyData.Append("The current capacity is: " + this.m_CurrentEnergyQuantity + " liters" + System.Environment.NewLine);

            return EnergyData;
        }
    }
}
